﻿using AutoMapper;
using Traceability_2203.Api.Application.Commands.USer;
using Traceability_2203.Api.Controllers;
using Traceability_2203.Common.Domain;
using Traceability_2203.Common.Dto;
using static Traceability_2203.Api.Controllers.IDCardDto;
namespace Traceability_2203.Api.Common
{
    /// <summary>
    /// 配置AutoMapper映射关系
    /// </summary>
    public class AutoMapperProfile:Profile
    {


        public AutoMapperProfile() {

            //用户用户新增的映射 由 新增用户的入参 转换 为 用户实体
            CreateMap<USersCreateCommand, Users>();
            //相互转换
            CreateMap<Users, UsersDto>().ReverseMap();
            //两个对象 树形名换不相同 Age==>UserAge
            //ForMember指向    从name 转换为 UserName
            CreateMap<Peole, Person>().ForMember(x=>x.UserName,y=>y.MapFrom(k=>k.name))
                                       .ForMember(x => x.UserAge, y => y.MapFrom(k => k.Age));
            //两个对象 树形 数据类型 不相同 string==>int  string ==>DateTime
        }


    }
}
